export default class MyControl extends window.BMap.Control {

  constructor () {
    super()
    this.defaultAnchor = window.BMAP_ANCHOR_TOP_LEFT
    this.defaultOffset = new BMap.Size(10, 10)
  }

  initialize (map) {
    const div = document.createElement('div')
    const divZoomIn = document.createElement('div')
    const divZoomOut = document.createElement('div')
    const zoomIn = document.createTextNode('放大两倍')
    const zoomOut = document.createTextNode('缩小两倍')

    Object.assign(div.style, {
      cursor: 'pointer',
      border: '1px solid gray',
      backgroundColor: '#FFF'
    })

    divZoomIn.onclick = () => {
      map.zoomTo(map.getZoom() + 2)
    }
    divZoomOut.onclick = () => {
      map.zoomTo(map.getZoom() - 2)
    }

    divZoomIn.appendChild(zoomIn)
    divZoomOut.appendChild(zoomOut)
    div.appendChild(divZoomIn)
    div.appendChild(divZoomOut)
    map.getContainer().appendChild(div)

    return div
  }
}
